// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

var CreatorHelper = require('CreatorHelper')
var ClickManager = require('ClickManager')

cc.Class({
    extends: cc.Component,

    properties: {
        id: 0,
        innings: 0,
        tid: cc.Label,
        tidString: 0,
        content: cc.Label,
        time: cc.Label,

        detailsNode: cc.Node
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        CreatorHelper.setNodeClickEvent(this.detailsNode, () => {
            ClickManager.ccSetCache('__DTID__', this.tidString)
            ClickManager.ccSetCache('__DINNINGS__', this.innings)

            var detailsModel = cc.find('Canvas/bg/model_score_details')
            detailsModel.active = true
        })
    },

    init (data) {
        this.id = data.id
        this.tidString = data.tid
        this.innings = data.innings
        this.tid.string = '牌桌id： ' + data.tid
        this.content.string = '输赢：' + data.win + '   局数：' + data.innings
        this.time.string = data.create_time
    }
    // update (dt) {},
});
